package com.eternal.notification.view;

import androidx.databinding.BindingAdapter;
import androidx.databinding.InverseBindingAdapter;
import androidx.databinding.InverseBindingListener;

/**
 * Created by Administrator
 * On 2020/5/9
 * Description:
 * @author Administrator
 */
public class TitleSelectViewAdapter {

    @BindingAdapter(value = {"select"})
    public static void setSelect(TitleSelectView view, boolean s){
        if(view.getSelect()!=s){
            view.setSelect(s);
        }
    }

    @InverseBindingAdapter(attribute = "select", event = "selectAttrChange")
    public static boolean getSelect(TitleSelectView view){
        return view.getSelect();
    }

    @BindingAdapter(value = {"selectAttrChange"})
    public static void selectAttrChange(TitleSelectView view, final InverseBindingListener listener){
        view.setSelectListener(new TitleSelectView.OnSelectListener() {
            @Override
            public void onchange(boolean b) {
                listener.onChange();
            }
        });
    }

    @BindingAdapter(value = {"title"})
    public static void setTitle(TitleSelectView view, String title){
        view.setTitle(title);
    }

    @BindingAdapter(value = {"info"})
    public static void setInfo(TitleSelectView view, String info){
        view.setInfo(info);
    }
}
